<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/header::common_header(~{::title},~{::link},~{})">
    <title>添加设备</title>
    <link rel="stylesheet" href="/css/index.css" type="text/css">
</head>
<body>
<div th:replace="common/bar::topbar" style="height: 100%"></div>
<div class="container-fluid">
    <div class="row">
        <!--左边导航栏-->
        <div th:replace="common/bar::#sidebar"></div>
        <!--//中间表格栏-->
        <div>

            <form class="border" style="padding: 20px;margin: 10px">

                <div class="form-group">
                    <svg class="bi bi-arrow-right-circle" width="1em" height="1em" viewBox="0 0 16 16"
                         fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                        <path fill-rule="evenodd"
                              d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
                        <path fill-rule="evenodd"
                              d="M7.646 11.354a.5.5 0 0 1 0-.708L10.293 8 7.646 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0z"/>
                        <path fill-rule="evenodd" d="M4.5 8a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5z"/>
                    </svg>
                    <label for="cardDesc">持卡人</label>
                    <input type="text" class="form-control" id="cardDesc" placeholder="请输入持卡人" name="cardDesc">
                </div>

                <button type="button" class="btn btn-secondary" style="margin-left: 150px" id="create"
                        onclick="addDevice()">
                    创建
                </button>
            </form>

        </div>
        <p style="color: red; margin-left: 5px" id="msg"></p>
    </div>
</div>
</body>
</html>


<script>
    function addDevice() {
        var cardDesc = $("#cardDesc").val();
        document.getElementById("msg").innerHTML = "请等待大约10秒....";
        $.post(
            "/data/keyCard/api/createCardMaster",
            {
                cardDesc: cardDesc
            },
            function (data) {
                if (data.code == "201") {
                    alert(data.code + ":" + data.message)
                    window.location.href = "list"
                } else {
                    alert(data.code + ":" + data.message)
                }
            })
    }

</script>
